#!/bin/bash

#功能: 介绍几种shell中循环遍历的方法

str="hello this test not all baby"

#1. for循环
echo "--------for demo1--------"
for item in $str;
do
    echo $item
done

for item in {a..z}; #a-z字符集
do
    echo $item
done

for item in {1..5}; #1-5字符集
do
    echo $item
done

#1.1. for循环方法2
echo "--------for demo2--------"
for ((i=0;i<5;i++))
{
    echo $i
}

#2. while循环
echo "--------while demo--------"
count=0
while [ $count -le 5 ];
do
    echo $count
    let count++
done


#3. until循环
echo "--------until demo--------"
x=0
until [ $x -eq 5 ];
do 
    echo $x
    let x++
done 